﻿<UserControl x:Class="Bricks.BaseFramework.GenericControls.TitleBar"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="24" d:DesignWidth="300" Loaded="UserControl_Loaded">
    <Grid>
        <!--以下请勿删除，此项可以保证点击TitleBar任何一处都可移动-->
        <Grid.Resources>
            <!--最小化按钮样式-->
            <Style TargetType="{x:Type Button}" x:Key="minStyle">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Width" Value="15" />
                <Setter Property="Height" Value="15" />                
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Grid>
                                <Image Source="/BaseFramework;component/Images/TitleBar/minimize_default.png" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/minimize_over.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/minimize_down.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <!--最大化按钮样式-->
            <Style TargetType="{x:Type Button}" x:Key="maxStyle">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Width" Value="15" />
                <Setter Property="Height" Value="15" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Grid>
                                <Image Source="/BaseFramework;component/Images/TitleBar/maximize_default.png" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/maximize_over.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/maximize_down.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <!--还原按钮样式-->
            <Style TargetType="{x:Type Button}" x:Key="restoreStyle">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Width" Value="15" />
                <Setter Property="Height" Value="15" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Grid>
                                <Image Source="/BaseFramework;component/Images/TitleBar/restore_default.png" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/restore_over.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/restore_down.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <!--关闭按钮样式-->
            <Style TargetType="{x:Type Button}" x:Key="closeStyle">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Width" Value="15" />
                <Setter Property="Height" Value="15" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Grid>
                                <Image Source="/BaseFramework;component/Images/TitleBar/close_default.png" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/close_over.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Button}">
                                    <Grid>
                                        <Image Source="/BaseFramework;component/Images/TitleBar/close_down.png" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>

        <WrapPanel VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10,0,0,0">
            <Image Name="imgLeftTop" HorizontalAlignment="Left" VerticalAlignment="Center" Width="16" Height="16"></Image>
            <Label Name="LblTiltleContent" Foreground="White" FontWeight="Bold" FontSize="15"></Label>
        </WrapPanel>
        <WrapPanel VerticalAlignment="Bottom" HorizontalAlignment="Right">
            <!--Focusable="False"可保证点击时不出现虚框-->
            <Button Name="btnMin" Style="{StaticResource minStyle}" Click="btnMin_Click" Focusable="False" Margin="2,0" />
            <Button Name="btnMax" Style="{StaticResource maxStyle}" Click="btnMax_Click" Focusable="False" Margin="2,0" />
            <Button Name="btnRestore" Style="{StaticResource restoreStyle}" Click="btnMax_Click" Visibility="Collapsed" Focusable="False" Margin="2,0" />
            <Button Name="btnClose" Style="{StaticResource closeStyle}" Click="btnClose_Click" Focusable="False" Margin="2,0,5,0" />
            </WrapPanel>
    </Grid>
</UserControl>
